@isTest
private class PDFReportControllerTest {
	@testSetup
	static void createWorkOrder(){

		Province__c pvin = new Province__c();
		pvin.Name ='四川';
		insert pvin ; 

		City__c ct = new City__c();
		ct.Name = '成都市';
		ct.Province__c = pvin.Id  ; 
		insert ct ;
		District__c dt = new District__c();
		dt.City__c  = ct.Id ; 
		dt.Name = '郫县';
		insert dt ; 

		Account acc = TestUtils.createAccount();
		acc.Level__c = '一级医院';
		acc.Province__c  = pvin.Id ; 
		acc.City__c = ct.Id; 
		acc.District__c = dt.Id; 

		insert acc;

		  Brand__c brand = new Brand__c(
            Name = '迈克生物',
            BrandShortName__c = '迈克生物'
            );
        insert brand;
		 //创建产品结构
        ProductStructure__c ps1 = new ProductStructure__c(
        	Classify1__c='仪器'
        );
        insert ps1;
		Product__c pro = TestUtils.createProduct();
		pro.Category0__c='仪器';
		pro.ProductStructure__c = ps1.Id ; 
		pro.CRMBrand__c = brand.Id;
		pro.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('NCProduct', 'Product__c');

		insert pro;

		Dealer__c d = new Dealer__c(
        Name = 'xxxxx',
        Only__c = '13455666'

        );
      insert d;


		InstallationApply__c IA = new InstallationApply__c();
        //IA.Name='安装申请测试1';
        IA.Instrument__c=pro.Id;
        IA.NEWDealer__c = d.Id;
        IA.Hospital__c = acc.Id;
         IA.InstallEstiDate__c = Date.newInstance(2018, 12, 1);
        IA.InstallsNumber__c = 1;
        IA.EffectiveTime__c = System.now();
            insert IA;



		Case case1 = new Case(
			RecordTypeId=Utils.getRecordTypeIdByDevNameAndObjName('Installation', 'Case'),
			Account=acc,
			Origin='电话',
			Status='处理中',
			InstallationApply__c= ia.Id ,

			Manufacturer__c=pro.Id);
		insert case1;
        
        Case case2 = new Case(
			RecordTypeId=Utils.getRecordTypeIdByDevNameAndObjName('Service', 'Case'),
			Account=acc,
			Origin='电话',
			Status='处理中',
			Manufacturer__c=pro.Id);
		insert case2;
        
		WorkOrder__c WO = new WorkOrder__c(
			RecordTypeId=Utils.getRecordTypeIdByDevNameAndObjName('InstallationOrder', 'WorkOrder__c'),
			Case__c=case1.Id,
        	ManufactureInfo__c=pro.Id,
			Status__c='生单',
			WhetherToMakeASingle__c='否');
		insert WO;
		Attachment att1 = new Attachment(
			Name='使用科室负责人_Sign.jpg',
			Body=Blob.ValueOf('123'),
			ParentId=WO.Id);
		insert att1;
		Attachment att2 = new Attachment(
			Name='管理科室负责人_Sign.jpg',
			Body=Blob.valueOf('123'),
			ParentId=WO.Id);
		insert att2;
		Attachment att3 = new Attachment(
			Name='工程师_Sign.jpg',
			Body=Blob.valueOf('123'),
			ParentId=WO.Id);
		insert att3;


		WorkOrder__c WO2 = new WorkOrder__c(
			RecordTypeId=Utils.getRecordTypeIdByDevNameAndObjName('ServiceOrder', 'WorkOrder__c'),
			Case__c=case2.Id,
			Status__c='生单',
			WhetherToMakeASingle__c='否');
		insert WO2;
System.Test.startTest();
		Attachment att4 = new Attachment(
			Name='使用科室负责人_Sign.jpg',
			Body=Blob.ValueOf('123'),
			ParentId=WO2.Id);
		insert att4;
		Attachment att5 = new Attachment(
			Name='管理科室负责人_Sign.jpg',
			Body=Blob.valueOf('123'),
			ParentId=WO2.Id);
		insert att5;
		Attachment att6 = new Attachment(
			Name='工程师_Sign.jpg',
			Body=Blob.valueOf('123'),
			ParentId=WO2.Id);
		insert att6;

		WorkOrder__c WO3 = new WorkOrder__c(
			RecordTypeId=Utils.getRecordTypeIdByDevNameAndObjName('MaintenanceOrder', 'WorkOrder__c'),
			Case__c=case2.Id,
			Status__c='生单',
			WhetherToMakeASingle__c='否',
			Maintenance_Content__c = '11111111111111111111111本测试文本测试文本测试文本测试文本测试文本测试文本本测试文本测试文本测试文本测试文本测试文本测试文本本测试文本测试文本测试文本测试文本测试文本测试文本');
		insert WO3;

		Attachment att7 = new Attachment(
			Name='使用科室负责人_Sign.jpg',
			Body=Blob.ValueOf('123'),
			ParentId=WO3.Id);
		insert att7;        
        
                //仪器培训
        WorkOrder__c WO4 = new WorkOrder__c(
RecordTypeId=Utils.getRecordTypeIdByDevNameAndObjName('InstrumentsTraining', 'WorkOrder__c'),
Case__c=case2.Id,
            ServiceSituation__c = '测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本',
            Install_Start_Datetime__c=Date.newInstance(2017,4,1),
            Install_End_Datetime__c=Date.newInstance(2017,4,2),
            ResultsSuggestions__c='测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本',
Status__c='生单',
WhetherToMakeASingle__c='否');
insert WO4;
        //技术巡回 技术服务
        WorkOrder__c WO5 = new WorkOrder__c(
RecordTypeId=Utils.getRecordTypeIdByDevNameAndObjName('TechnicalTours', 'WorkOrder__c'),
Case__c=case2.Id,
            ServiceSituation__c = '测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本',
            Install_Start_Datetime__c=Date.newInstance(2017,4,1),
            Install_End_Datetime__c=Date.newInstance(2017,4,2),            
            ResultsSuggestions__c='测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本测试文本',
Status__c='生单',
WhetherToMakeASingle__c='否');
insert WO5;

    
	}

    static testMethod void testMethod1() {
    	String recordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('InstallationOrder', 'WorkOrder__c');
        WorkOrder__c workOrder = [SELECT Id FROM WorkOrder__c WHERE RecordTypeId= : recordTypeId LIMIT 1];
        System.debug(LoggingLevel.INFO, '*** workOrder: ' + workOrder);
        if(null == workOrder){
        	System.debug(LoggingLevel.INFO, '*** workOrder is null: ');
        	return;
        }
        ApexPages.StandardController stdCon = new ApexPages.StandardController(workOrder);
        InstallationReportController con = new InstallationReportController(stdCon);
    }
    static testMethod void testMethod2() {
    	String recordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('ServiceOrder', 'WorkOrder__c');
    	WorkOrder__c workOrder = [SELECT Id FROM WorkOrder__c WHERE RecordTypeId= : recordTypeId LIMIT 1];
        System.debug(LoggingLevel.INFO, '*** workOrder: ' + workOrder);
        if(null == workOrder){
        	System.debug(LoggingLevel.INFO, '*** workOrder is null: ');
        	return;
        }
        ApexPages.StandardController stdCon = new ApexPages.StandardController(workOrder);
        ServiceReportController con = new ServiceReportController(stdCon);
    }
    static testMethod void testMethod3(){
    	String recordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('MaintenanceOrder', 'WorkOrder__c');
    	WorkOrder__c workOrder = [SELECT Id FROM WorkOrder__c WHERE RecordTypeId= : recordTypeId LIMIT 1];
        System.debug(LoggingLevel.INFO, '*** workOrder: ' + workOrder);
        if(null == workOrder){
        	System.debug(LoggingLevel.INFO, '*** workOrder is null: ');
        	return;
        }
        ApexPages.StandardController stdCon = new ApexPages.StandardController(workOrder);
        MaintenanceReportController con = new MaintenanceReportController(stdCon);
    }
        //仪器培训
      static testMethod void testMethod4(){
    String recordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('InstrumentsTraining', 'WorkOrder__c');
    WorkOrder__c workOrder = [SELECT Id FROM WorkOrder__c WHERE RecordTypeId= : recordTypeId LIMIT 1];
        System.debug(LoggingLevel.INFO, '*** workOrder: ' + workOrder);
        if(null == workOrder){
        System.debug(LoggingLevel.INFO, '*** workOrder is null: ');
        return;
        }
        PageReference page = new PageReference('/apex/EquipmentIntroduce?id=' +workOrder.Id);
        System.Test.setCurrentPage(page);
        ApexPages.StandardController stdCon = new ApexPages.StandardController(workOrder);

        EquipmentIntroduceController con = new EquipmentIntroduceController(stdCon);
        con.init();
    }
    //技术巡回
     static testMethod void testMethod5(){
    String recordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('TechnicalTours', 'WorkOrder__c');
    WorkOrder__c workOrder = [SELECT Id FROM WorkOrder__c WHERE RecordTypeId= : recordTypeId LIMIT 1];
        System.debug(LoggingLevel.INFO, '*** workOrder: ' + workOrder);
        if(null == workOrder){
        System.debug(LoggingLevel.INFO, '*** workOrder is null: ');
        return;
        }
        ApexPages.StandardController stdCon = new ApexPages.StandardController(workOrder);
        TechnicalServiceController con = new TechnicalServiceController(stdCon);
         con.init();
    }
}